package org.feng.businessbean;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.feng.common.BeanBusiness;
import org.feng.common.BusinessOneEnum;
import org.feng.common.BusinessTwoEnum;

import javax.annotation.PostConstruct;

/**
 * TODO 类的描述
 *
 * @version V1.0
 * @author: fengjinsong
 * @date: 2022年07月01日 16时08分
 */
@Slf4j
@Getter
@ToString
public abstract class MyBean {
    @Setter(AccessLevel.NONE)
    private BusinessOneEnum one;
    @Setter(AccessLevel.NONE)
    private BusinessTwoEnum two;

    @PostConstruct
    private void setProperties() {
        // 当前类是业务bean
        if (this.getClass().isAnnotationPresent(BeanBusiness.class)) {
            BeanBusiness beanBusiness = this.getClass().getAnnotation(BeanBusiness.class);
            this.one = beanBusiness.one();
            this.two = beanBusiness.two();
        }
    }

    public void doSome() {
        log.info("one={} tow={}", one, two);
    }
}
